package com.heima.media.controller;


import com.heima.common.dto.ResponseResult;
import com.heima.media.dto.ChannelDto;
import com.heima.media.entity.WmChannel;
import com.heima.media.service.IWmChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("avi/v1/channel")
@Api(tags = "频道管理API")
public class ChannelController {
//注入服务层接口
    @Autowired(required = false)
    private IWmChannelService channelService;

    /**
     * 分页查询频道列表
     * @param dto
     * @return
     */
    @PostMapping("list")
    @ApiOperation(value = "分页查询频道列表",notes = "Author:mcm")
    @ApiImplicitParam(name = "dto",value ="请求对象" ,required = true,dataType = "ChannelDto")
    public ResponseResult listByPage(@RequestBody ChannelDto dto) {
        return channelService.listByPage(dto);
    }

    /**
     * 新增频道
     * @param channel
     * @return
     */
    @PostMapping
    @ApiOperation(value = "新增频道",notes = "Author:mcm")
    @ApiImplicitParam(name = "channel",value ="频道对象" ,required = true,dataType = "ChannelDto")
    //保存频道
    public ResponseResult saveChannel(@RequestBody WmChannel channel){//此处对象需要注解name一致
        return channelService.saveChannel(channel);

    }
}
